#ifndef __SDL_VIEW_HPP__
#define __SDL_VIEW_HPP__

#include <memory>
#include <string>
#include "core.hpp"
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"

typedef struct DrawState
{
    DrawState()
        : originPoint( 0, 0 ),
        anchor( 0.5, 0.5 ),
        rotation( 0 ),
        scale( 1, 1 )
    {
    }
    PointFloat originPoint;
    PointFloat anchor;
    float rotation;
    PointFloat scale;
}DrawState;

class SDLView
{
public:
    SDL_Window* window;
    SDL_Renderer* windowRenderer;
    SDL_Renderer* renderer;
    SDL_Texture* screenTexture;

    int screenWidth, screenHeight;
    SDL_Rect __screenRect;
    Size __designSize;
    PointFloat scale;

    DrawState drawState;
    DrawState curDrawState;

    TTF_Font* font;
    Color drawColor;
    PointFloat drawScale;


    SDLView( std::string const& title = "app", int width = 640, int height = 480, int designWidth = 640, int designHeight = 480, Uint32 windowFlags = SDL_WINDOW_SHOWN, std::string const& fontName = "ARIAL.TTF" );
    ~SDLView();
    void drawImage( SDL_Texture* texture, SDL_Rect* dstRect, SDL_Rect* srcRect = nullptr, float rotation = 0, float scaleX = 1, float scaleY = 1, SDL_RendererFlip flip = SDL_FLIP_NONE );

    //void resetWindow( int width, int height, Uint32 windowFlags, std::string const& title = "" );

    void setDrawColor( Uint8 r, Uint8 g, Uint8 b, Uint8 a = -1 );
    Color getDrawColor();
    void drawRect( const SDL_Rect* rect );


    void present();

};
#endif //__SDL_VIEW_HPP__